package com.tuoyu.peopletest.view.custom;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.cardview.widget.CardView;

import com.tuoyu.peopletest.R;


public class Btn03View extends RelativeLayout {

    private final TextView tvText;

    public Btn03View(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.view_btn03, this);
        tvText = findViewById(R.id.tv_text);
        //CardView v_top = findViewById(R.id.v_top);
        ImageView iv = findViewById(R.id.iv);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Btn03View);
        if (a != null) {
            String text = a.getString(R.styleable.Btn03View_btn03_text);
            tvText.setText(text);

            int resourceId01 = a.getResourceId(R.styleable.Btn03View_btn03_iv, 0);
            int resourceId02 = a.getResourceId(R.styleable.Btn03View_btn03_iv_bg, 0);

            if (resourceId01 != 0) {
                iv.setImageResource(resourceId01);
            }


            if (resourceId02 != 0) {
                iv.setBackgroundResource(resourceId02);

            }
            a.recycle();
        }
    }
}
